//
//  CellTableViewReceiveGoods.m
//  Youhuiju
//
//  Created by liuovyue on 16/8/31.
//  Copyright © 2016年 yutenys. All rights reserved.
//

#import "CellTableViewReceiveGoods.h"
#import "LogisticsViewController.h"

@interface CellTableViewReceiveGoods()
@property (strong, nonatomic) IBOutlet UIButton *buttonSure;

@property (strong, nonatomic) IBOutlet UIImageView *imageGoods;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *imageWidth;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *imageHeight;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *imageTop;

//商品名字
@property (strong, nonatomic) IBOutlet UILabel *labelGoods;
//七天退换
@property (strong, nonatomic) IBOutlet UILabel *labelSevenDays;

//支付价钱
@property (strong, nonatomic) IBOutlet UILabel *labelPayMoney;

//原价
@property (strong, nonatomic) IBOutlet UILabel *labelList;


//数量
@property (strong, nonatomic) IBOutlet UILabel *labelNumber;

//含运费

@property (strong, nonatomic) IBOutlet UILabel *labelShipment;
//订单合计
@property (strong, nonatomic) IBOutlet UILabel *labelAll;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *allTop;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *allBot;



//共 1 件
@property (strong, nonatomic) IBOutlet UILabel *labelProductsNumber;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *productsBot;


//两条横线

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *viewTwoBot;



//快递
@property (strong, nonatomic) IBOutlet UILabel *labelKuaidi;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *kuaidiLead;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *kuaidiTop;



//快递价钱
@property (strong, nonatomic) IBOutlet UILabel *labelKuaidiMoney;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *kuaidiMoneyLead;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *kuaidiMoneyTop;


//实际购买商品价格
@property (strong, nonatomic) IBOutlet UILabel *labelActualMoney;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *actualMoneyTop;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *actualMoneyBot;



@property (strong, nonatomic) IBOutlet UIView *viewOne;

@property (strong, nonatomic) IBOutlet UIView *viewTwo;

//查看物流距离适配
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookExpressLead;


@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookExpressTwoWidth;

//确认收货距离
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookExpressWidth;

//联系我们距离
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *contractWeWidth;
//取消订单距离
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *cancelOrdersWidth;
//付款距离
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *payMoneyWidth;
//待发货的物流查看 距离
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookExpressNewWidth;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *lookExpressNewHeight;
//删除订单距离
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *deleteOrdersWidth;
//评价距离
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *evaluationWidth;

@end


@implementation CellTableViewReceiveGoods

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.viewTwoBot.constant = 17*FitH;
    
    
    self.imageWidth.constant = 90*FitW;
    self.imageHeight.constant = 90*FitH;
    self.imageTop.constant = 15*FitH;
    
    self.lookExpressLead.constant = 193*FitW;
    
    self.lookExpressWidth.constant = 80*FitW;
    
    self.lookExpressTwoWidth.constant = 80*FitW;
    
    self.contractWeWidth.constant = 80*FitH;
    self.cancelOrdersWidth.constant = 80*FitH;
    self.payMoneyWidth.constant = 80*FitH;
    
    self.lookExpressNewWidth.constant = 80*FitW;
    self.lookExpressNewHeight.constant = 30*FitW;
    
    self.evaluationWidth.constant = 80*FitW;
    
    self.deleteOrdersWidth.constant = 80*FitW;
    
    self.viewOne.backgroundColor = [UIColor colorWithHexString:@"efefef"];
    self.viewTwo.backgroundColor = [UIColor colorWithHexString:@"efefef"];

    [self.buttonSure setImage:[UIImage imageNamed:@"1-kongxinyuan"] forState:UIControlStateNormal];
    
    [self.buttonSure setImage:[UIImage imageNamed:@"1-shixinyuan"] forState:UIControlStateSelected];
    
    
    self.labelGoods.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelGoods.numberOfLines = NO;
    self.labelGoods.font = [UIFont systemFontOfSize:12*FitW];
    
    self.labelSevenDays.textColor = [UIColor colorWithHexString:@"e60012"];
    self.labelSevenDays.font = [UIFont systemFontOfSize:11*FitW];
    
    self.labelPayment.textColor = [UIColor colorWithHexString:@"fc527d"];
    self.labelPayment.font = [UIFont systemFontOfSize:12*FitW];
    
    self.labelPayMoney.textColor = [UIColor colorWithHexString:@"333333"];
    self.labelPayMoney.font = [UIFont systemFontOfSize:12*FitW];
   
    self.labelList.textColor = [UIColor colorWithHexString:@"999999"];
    NSUInteger length = [self.labelList.text length];
    
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:self.labelList.text];
    
    
  
    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(1, length-1)];
    
    [self.labelList setAttributedText:attri];
    self.labelPayMoney.font = [UIFont systemFontOfSize:12*FitW];
    
    self.labelNumber.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelNumber.font = [UIFont systemFontOfSize:12*FitW];

    
    self.labelShipment.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelShipment.font = [UIFont systemFontOfSize:14*FitW];
 
    self.labelAll.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelAll.font = [UIFont systemFontOfSize:14*FitW];

    self.allTop.constant = 20*FitH;
    
    self.allBot.constant = 11*FitH;
    self.productsBot.constant = 11*FitH;
    self.kuaidiLead.constant = 215*FitW;
    
    
    
    
    self.labelProductsNumber.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelProductsNumber.font = [UIFont systemFontOfSize:14*FitW];

    
    self.labelKuaidi.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelKuaidi.font = [UIFont systemFontOfSize:14*FitW];
    self.kuaidiTop.constant = 17*FitH;
    self.kuaidiMoneyTop.constant = 17*FitH;
    self.actualMoneyTop.constant = 14*FitH;
    self.labelKuaidiMoney.textColor = [UIColor colorWithHexString:@"999999"];
    self.kuaidiMoneyLead.constant =15*FitW;
    
    self.labelKuaidiMoney.font = [UIFont systemFontOfSize:14*FitW];
    self.labelActualMoney.textColor = [UIColor colorWithHexString:@"333333"];
    self.labelActualMoney.font = [UIFont systemFontOfSize:14*FitW];
self.actualMoneyBot.constant = 19*FitH;
    
    
    [self.buttonLookExpress.layer setMasksToBounds:YES];
    [self.buttonLookExpress.layer setBorderWidth:1.0f];
    [self.buttonLookExpress.layer setCornerRadius:2.0];
    self.buttonLookExpress.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    self.buttonLookExpress.layer.borderColor = [UIColor colorWithHexString:@"#fd487f"].CGColor;
    
    [self.buttonSureGoods.layer setCornerRadius:2.0];
    self.buttonSureGoods.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    
    self.buttonSureGoods.backgroundColor = [UIColor colorWithHexString:@"#fd487f"];
    
//    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
//    gradientLayer.frame = self.buttonSureGoods.bounds;
//    
//    
//    gradientLayer.colors = @[(id)[UIColor colorWithHexString:@"#fd487f"].CGColor,
//                             (id)[UIColor colorWithHexString:@"#ff9a64"].CGColor];
//    
//    gradientLayer.startPoint = CGPointMake(0, 0);
//    gradientLayer.endPoint = CGPointMake(1, 1);
//    
//    [self.buttonSureGoods.layer setMasksToBounds:YES];
//    [self.buttonSureGoods.layer addSublayer:gradientLayer];
    self.buttonSureGoods.tintColor = [UIColor whiteColor];
    
    [self.buttonContractWe.layer setMasksToBounds:YES];
    [self.buttonContractWe.layer setCornerRadius:2.0f];
    [self.buttonContractWe.layer setBorderWidth:1.0f];
    self.buttonContractWe.layer.borderColor = [UIColor colorWithHexString:@"#fd487f"].CGColor;
    self.buttonContractWe.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    
    
    
    //待评价页面
    [self.deleteOrder.layer setMasksToBounds:YES];
    [self.deleteOrder.layer setCornerRadius:2.0f];
    [self.deleteOrder.layer setBorderWidth:1.0f];
    self.deleteOrder.layer.borderColor = [UIColor colorWithHexString:@"#fd487f"].CGColor;
    self.deleteOrder.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    

    [self.buttonEvaluation.layer setCornerRadius:2.0];
    self.buttonEvaluation.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    
    self.buttonEvaluation.backgroundColor = [UIColor colorWithHexString:@"#fd487f"];
    self.buttonEvaluation.tintColor = [UIColor whiteColor];
    //待付款页面
    [self.buttonPayment.layer setCornerRadius:2.0];
    self.buttonPayment.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    
    self.buttonPayment.backgroundColor = [UIColor colorWithHexString:@"#fd487f"];
    self.buttonPayment.tintColor = [UIColor whiteColor];
    
    [self.cancelOrders.layer setMasksToBounds:YES];
    [self.cancelOrders.layer setCornerRadius:2.0f];
    [self.cancelOrders.layer setBorderWidth:1.0f];
    self.cancelOrders.layer.borderColor = [UIColor colorWithHexString:@"#fd487f"].CGColor;
    self.cancelOrders.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    
    [self.buttonContractWe.layer setMasksToBounds:YES];
    [self.buttonContractWe.layer setCornerRadius:2.0f];
    [self.buttonContractWe.layer setBorderWidth:1.0f];
    self.buttonContractWe.layer.borderColor = [UIColor colorWithHexString:@"#fd487f"].CGColor;
    self.buttonContractWe.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    
    
    //待发货页面
    self.buttonlookExpressTwo.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    
    [self.buttonlookExpressTwo.layer setMasksToBounds:YES];
    [self.buttonlookExpressTwo.layer setCornerRadius:2.0f];
    [self.buttonlookExpressTwo.layer setBorderWidth:1.0f];
    self.buttonlookExpressTwo.layer.borderColor = [UIColor colorWithHexString:@"#fd487f"].CGColor;
    self.buttonlookExpressTwo.titleLabel.font = [UIFont systemFontOfSize:16*FitW];
    
}

- (IBAction)sureAction:(UIButton *)sender {
    
    sender.selected = !sender.selected;
}

//待收货
- (IBAction)lookExpress:(id)sender {
    NSLog(@"查看物流");
}

- (IBAction)sureGoods:(id)sender {
    NSLog(@"确认收货");
}

//交易完成(和待收货共用一个查看物流)


- (IBAction)deleteOrder:(id)sender {
    NSLog(@"删除订单");
}

- (IBAction)evaluttionAction:(id)sender {
    NSLog(@"评价");
}


//待发货的查看物流
- (IBAction)lookExpressTwoAction:(id)sender {
    NSLog(@"待发货的查看物流");
    LogisticsViewController *logis = [[LogisticsViewController alloc]init];
   
    
    id object = [self nextResponder];
    while (![object isKindOfClass:[UIViewController class]]&&object != nil) {
        
        
        object = [object nextResponder];
        
    }
    
    
    UIViewController *vc = (UIViewController *)object;
    [vc.navigationController pushViewController:logis animated:YES];
    
   
}

//待付款
- (IBAction)contactWe:(id)sender {
    NSLog(@"联系我们");
}

- (IBAction)paymentAction:(id)sender {

    NSLog(@"支付");

}
- (IBAction)cancelOrder:(id)sender {
    NSLog(@"取消订单");
}


//交易成功






- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
